home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / filesyst / ncpfs / mars_dos.000 / mars_dos / netpc / net.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-21  |  6.6 KB  |  221 lines

  1. /* net.h: 20-May-96 */
  2.  
  3. /****************************************************************
  4.  * (C)opyright (C) 1993,1996  Martin Stover, Marburg, Germany   *
  5.  ****************************************************************/
  6.  
  7. #include <stddef.h>
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include <malloc.h>
  11. #include <string.h>
  12. #include <conio.h>
  13. #include <io.h>
  14. #include <bios.h>
  15. #include <dos.h>
  16. #include <process.h>
  17. #include <stdarg.h>
  18.  
  19. typedef unsigned int       UI;
  20. typedef unsigned int       uint;
  21. typedef unsigned char      UC;
  22. typedef unsigned char      uint8;
  23. typedef unsigned short int uint16;
  24. typedef unsigned long  int uint32;
  25.  
  26. typedef union  REGS  REGS;
  27. typedef struct SREGS SREGS;
  28.  
  29. typedef void  (*FUNC_VOID)();
  30. typedef int   (*FUNC_INT)();
  31.  
  32.  
  33. typedef struct {
  34.    uint8  checksum[2];
  35.    uint16  packetlen;
  36.    uint8  tcontrol;
  37.    uint8  ptype;
  38.    uint8  dest_net[4];
  39.    uint8  dest_node[6];
  40.    uint16  dest_sock;        /* HI LOW */
  41.    uint8  source_net[4];
  42.    uint8  source_node[6];
  43.    uint16  source_sock;      /* HI LOW */
  44. } IPX_HEADER;
  45.  
  46. typedef struct {
  47.   uint8        *link_address;
  48.   FUNC_VOID    esr_routine;
  49.   uint8        in_use_flag;
  50.   uint8        completition_code;
  51.   uint16       socket;               /* HI LOW                 */
  52.   uint8        ipx_workspace[4];     /* interner Gebrauch     */
  53.   uint8        drv_workspace[4];     /* interner Gebrauch     */
  54.   uint8        immediate_address[6]; /* HI LOW Node Address     */
  55.   uint16       fragment_count;       /* Anzahl Fragment Buffers */
  56.   uint8        *fragment_1;
  57.   uint16       fragment_1_size;
  58.   /* Können auch mehr sein */
  59. } ECB;
  60.  
  61. #include "kern.h"
  62.  
  63. #define UI2NET(i)  ( ( (i) << 8)  |  ( ((i)>>8) & 0xFF) )
  64. #define NET2UI(i)  ( ( (i) << 8)  |  ( ((i)>>8) & 0xFF) )
  65.  
  66. #define U16_TO_BE16(u, b) { uint16 a=(u); \
  67.                *(  (uint8*) (b) )    = *( ((uint8*) (&a)) +1); \
  68.                *( ((uint8*) (b)) +1) = *(  (uint8*) (&a)); }
  69.  
  70.  
  71. #define U32_TO_BE32(u, ar) { uint32 a= (u); uint8 *b= ((uint8*)(ar))+3; \
  72.                *b-- = (uint8)a; a >>= 8;  \
  73.                *b-- = (uint8)a; a >>= 8;  \
  74.                *b-- = (uint8)a; a >>= 8;  \
  75.                *b   = (uint8)a; }
  76.  
  77. #define U16_TO_16(u, b) { uint16 a=(u); memcpy(b, &a, 2); }
  78. #define U32_TO_32(u, b) { uint32 a=(u); memcpy(b, &a, 4); }
  79.  
  80. #define GET_BE16(b)  (     (int) *(((uint8*)(b))+1)  \
  81.                      | ( ( (int) *( (uint8*)(b)   )  << 8) ) )
  82.  
  83. #define GET_BE32(b)  (   (uint32)   *(((uint8*)(b))+3)  \
  84.                    | (  ((uint32)   *(((uint8*)(b))+2) ) << 8)  \
  85.                    | (  ((uint32)   *(((uint8*)(b))+1) ) << 16) \
  86.                    | (  ((uint32)   *( (uint8*)(b)   ) ) << 24) )
  87.  
  88.  
  89. #define GET_16(b)    (     (int) *( (uint8*)(b)   )  \
  90.                      | ( ( (int) *(((uint8*)(b))+1)  << 8) ) )
  91.  
  92. #define GET_32(b)    (   (uint32)   *( (uint8*)(b)   )  \
  93.                    | (  ((uint32)   *(((uint8*)(b))+1) ) << 8)  \
  94.                    | (  ((uint32)   *(((uint8*)(b))+2) ) << 16) \
  95.                    | (  ((uint32)   *(((uint8*)(b))+3) ) << 24) )
  96.  
  97. #define MAX_U32    ((uint32)0xffffffffL)
  98. #define MAX_U16    ((uint16)0xffff)
  99.  
  100. #define NWSERV   1
  101. #define NCPSERV  2
  102. #define NWCONN   3
  103. #define NWCLIENT 4
  104. #define NWBIND   5
  105.  
  106. /* net.c */
  107. extern char  *funcname;
  108. extern char   prgpath[];
  109.  
  110. extern int   call_func_entry(int argc, char *argv[]);
  111.  
  112. /* tools.c */
  113. extern void  clear_kb(void);
  114. extern int   key_pressed(void);
  115. extern int   ask_user(char *p, ...);
  116. #define xfree(p)      x_x_xfree((char **)&(p))
  117. extern  void x_x_xfree(char **p);
  118. extern char  *xmalloc(uint  size);
  119. extern char  *xcmalloc(uint size);
  120.  
  121. extern int   strmaxcpy(char *dest, char *source, int len);
  122. extern char  *xadd_char(char *s, int c, int maxlen);
  123. extern uint8 *upstr(uint8 *s);
  124. extern void korrpath(char *s);
  125. extern void get_path_fn(char *s, char *p, char *fn);
  126.  
  127. #define reb(s) deb((s)),leb((s))
  128.  
  129. extern void  deb(uint8 *s);
  130. extern void  leb(uint8 *s);
  131.  
  132.  
  133. #define add_char(s, c) xadd_char((s), (c), -1)
  134.  
  135. extern char *getglobenv(char *option);
  136. extern int  putglobenv(char  *option);
  137.  
  138. /* NETCALLS */
  139. #define DRIVE_ADD     1
  140. #define DRIVE_INSERT  2
  141. #define DRIVE_DELETE  3
  142.  
  143. typedef struct {
  144.   uint8  drivenummer;   /* 0xff=last of list,  0xfe only DOSPATH */
  145.   uint8  flags;         /* 0x80 = local drive */
  146.   char   dospath[65];
  147.   uint8  connid;
  148.   uint8  dhandle;
  149. } SEARCH_VECTOR_ENTRY;
  150.  
  151. typedef SEARCH_VECTOR_ENTRY  SEARCH_VECTOR[17];
  152.  
  153. extern int neterrno;
  154.  
  155. #define alloc_permanent_dir_handle(dhandle, path, drive, rights) \
  156.   alloc_dir_handle(0x12, (dhandle), (path), (drive), (rights))
  157.  
  158. #define alloc_temp_dir_handle(dhandle, path, drive, rights) \
  159.   alloc_dir_handle(0x13, (dhandle), (path), (drive), (rights))
  160.  
  161. extern int ipx_init(void);
  162.  
  163. extern int alloc_dir_handle(int func, int dhandle, char *path,
  164.                             int driveletter, uint8 *effrights);
  165.  
  166. extern int dealloc_dir_handle(int dhandle);
  167.  
  168. extern int get_dir_path(uint8 dhandle, char *path);
  169. extern int get_volume_name(uint8 nr, char *name);
  170.  
  171. extern int get_search_drive_vektor(SEARCH_VECTOR_ENTRY *vec);
  172. extern int set_search_drive_vektor(SEARCH_VECTOR_ENTRY *vec);
  173.  
  174. /********* ncpcall.h  ***********/
  175. extern  int   ncp_16_02(int dirhandle,
  176.               uint8  *path,
  177.               int    *sub_dir,
  178.               uint8  *resultpath,
  179.               uint32 *creattime,
  180.               uint32 *owner_id);
  181.  
  182. extern int    ncp_17_02(int   module, int debuglevel);
  183. extern int    ncp_17_14(uint8 *objname, uint16 objtyp, uint8 *password);
  184. extern int    ncp_17_17(uint8 *key);
  185. extern int    ncp_17_18(uint8 *cryptkey, uint8 *objname, uint16 objtyp);
  186. extern uint32 ncp_17_35(uint8 *objname, uint16 objtyp);
  187. extern int    ncp_17_40(uint8 *objname, uint16 objtyp, uint8 *password,
  188.                                                        uint8 *newpassword);
  189.  
  190. extern int    ncp_17_4b(uint8 *cryptkey, uint8 *objname, uint16 objtyp,
  191.                                int passwx, uint8 *newpassword);
  192.  
  193. /* map.c */
  194. extern int func_map   (int argc, char *argv[], int mode);
  195. extern int func_path  (int argc, char *argv[], int mode);
  196.  
  197. /* login.c */
  198. extern int func_login  (int argc, char *argv[], int mode);
  199. extern int func_logout (int argc, char *argv[], int mode);
  200. extern int func_passwd (int argc, char *argv[], int mode);
  201. extern int func_profile(int argc, char *argv[], int mode);
  202. extern int func_cwd    (int argc, char *argv[], int mode);
  203. extern int func_echo   (int argc, char *argv[], int mode);
  204. extern int func_exec   (int argc, char *argv[], int mode);
  205. extern int read_command_file(char *fstr);
  206.  
  207. /* slist.c */
  208. extern int func_slist (int argc, char *argv[], int mode);
  209.  
  210. /* nwdebug.c */
  211. extern int func_debug (int argc, char *argv[], int mode);
  212.  
  213. /* nwtests.c */
  214. extern int func_tests (int argc, char *argv[], int mode);
  215.  
  216. /* capture.c */
  217. extern int func_capture(int argc, char *argv[], int mode);
  218.  
  219.  
  220.  
  221.